using System;
using UnityEngine;

public class PictureBoxWidgetHandler : MonoBehaviour, IWidget, IHandlerBase
{
	public void SetData(int index, bool _isUp, int _tangramIndex, bool _isClear = true)
	{
		this.tangramIndex = _tangramIndex;
		this.isUp = _isUp;
		if (_isClear)
		{
			if (GameMode.gameMode == GameType.TRIANGLE)
			{
				this.sprite.spriteName = ((!this.isUp) ? "block_triangle_1" : "block_triangle_0");
			}
			else if (GameMode.gameMode == GameType.SQUARE)
			{
				this.sprite.spriteName = "block_square";
			}
			else if (GameMode.gameMode == GameType.HEXA)
			{
				this.sprite.spriteName = "block_hexa";
			}
			else if (GameMode.gameMode == GameType.RHOMBUS)
			{
				this.sprite.spriteName = "block_rhombus";
			}
			else if (GameMode.gameMode == GameType.TANGRAM)
			{
				this.sprite.spriteName = string.Format("block_tangram_{0}", this.tangramIndex);
			}
		}
		else if (GameMode.gameMode == GameType.TRIANGLE)
		{
			this.sprite.spriteName = ((!this.isUp) ? "background_triangle_1" : "background_triangle_0");
		}
		else if (GameMode.gameMode == GameType.SQUARE)
		{
			this.sprite.spriteName = "background_square";
		}
		else if (GameMode.gameMode == GameType.HEXA)
		{
			this.sprite.spriteName = "background_hexa";
		}
		else if (GameMode.gameMode == GameType.RHOMBUS)
		{
			this.sprite.spriteName = "background_rhombus";
		}
		else if (GameMode.gameMode == GameType.TANGRAM)
		{
			this.sprite.spriteName = string.Format("background_tangram_{0}", this.tangramIndex);
		}
		this.SetMesh(index, _isClear);
		this.DoDataExchange();
	}

	private void SetMesh(int index, bool isClear)
	{
		if (isClear)
		{
			this.sprite_ren.material.SetFloat("_OriginColor", 0f);
			this.sprite_ren.material.SetFloat("_MultiColor", 1f);
			if (index > -1 && index < 255)
			{
				MultiColorExt.SetColor(this.filter, index);
			}
		}
		else
		{
			this.sprite_ren.material.SetFloat("_OriginColor", 1f);
			this.sprite_ren.material.SetFloat("_MultiColor", 0f);
		}
	}

	public void DoDataExchange()
	{
	}

	public MeshFilter filter;

	public tk2dSprite sprite;

	public Renderer sprite_ren;

	public bool isUp;

	public int tangramIndex;
}
